﻿using System;
using System.Configuration;

namespace UFIDA.U9.WSS.ProxyService.AccessProxy.Configuration
{
    [ConfigurationCollection(typeof(ProxySection), AddItemName = "Proxy")]
    public class GroupSectionCollection : ConfigurationElementCollection
    {
        public GroupSectionCollection()
        {
            AddElementName = "Group";
        }

        protected override string ElementName
        {
            get { return "Group"; }
        }

        public GroupSection this[int index]
        {
            get { return (GroupSection) BaseGet(index); }
        }

        public new GroupSection this[string key]
        {
            get { return (GroupSection) BaseGet(key); }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new GroupSection();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException();
            }

            return ((GroupSection) element).Name;
        }

        public void Add(GroupSection e)
        {
            BaseAdd(e);
        }

        public void Remove(GroupSection e)
        {
            if (e != null)
            {
                BaseRemove(e.Name);
            }
        }

        public void Remove(string key)
        {
            BaseRemove(key);
        }

        public void Clear()
        {
            BaseClear();
        }
    }
}